package com.kepler.social.web.controller.converter;

import com.kepler.social.common.utils.Safes;
import com.kepler.social.domain.port.vo.CreateMoodCaseVo;
import com.kepler.social.domain.support.media.vo.FileSliceVo;
import com.kepler.social.web.controller.param.CreateMoodReq;

import java.util.Objects;
import java.util.stream.Collectors;

public class MoodConverter {

    public static CreateMoodCaseVo createMoodCaseVo(CreateMoodReq createMoodReq) {
        assert Objects.nonNull(createMoodReq);
        return CreateMoodCaseVo.builder()
                .seqNo(createMoodReq.getSeqNo())
                .content(createMoodReq.getContent())
                .title(createMoodReq.getTitle())
                .postType(createMoodReq.getPostType())
                .location(createMoodReq.getLocation())
                .fileSlices(
                        Safes.of(createMoodReq.getFileSlices()).stream().map(e ->
                                FileSliceVo.builder()
                                        .fileName(e.getFileName())
                                        .seqNo(e.getSeqNo())
                                        .mimeType(e.getMimeType())
                                        .build()
                        ).collect(Collectors.toList())
                ).build();
    }
}
